package vn.bang.xiangqi.server.thread;


public class BaseThread extends Thread {
	
	private boolean stopping = false;
	private Thread currentThread;
	private IProcess processor;
	
	@Override
	public void run() {
		currentThread = Thread.currentThread();
		while (!stopping) {
			processor.process();
		}
	}
	
	public void setProcessor(IProcess processor) {
		this.processor = processor;
	}
	
	public synchronized void shutdown() {
	    stopping = true;
	    if (null != currentThread) {
	    	currentThread.notifyAll();
	    }
	}

	public synchronized boolean isStopping() {
	    return stopping;
	}

}
